<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class MoneyLog extends Model
{
    //
    public function money_log_type()
    {
    	return $this->hasOne(MoneyLogType::class,'id','type_id');
    }
    public function user()
    {
    	return $this->hasOne(User::class,'id','user_id');
    }
    //获取资产明细
    public function get_user_moneylog($request)
    {
    	$user = $request->user;
    	$map = [];
    	$map['user_id'] = $user->id;
    	if($request->type){
    		$map['type_id'] = $request->type;
    	}

    	$data = $this->where($map)->with('money_log_type')->get();
    	return $data;
    }
}
